﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cheems.Interface.MQTT
{
    /// <summary>
    /// MQTT服务端接口
    /// </summary>
    public interface IMqttServer
    {
        /// <summary>
        /// 异步打开服务
        /// </summary>
        /// <param name="port"></param>
        /// <returns></returns>
        Task<bool> OpenAsync(int port);

        /// <summary>
        /// 异步关闭服务
        /// </summary>
        /// <returns></returns>
        Task<bool> CloseAsync();

        /// <summary>
        /// MQTT错误
        /// </summary>
        event Action<Exception> OnException;

        /// <summary>
        /// 打开连接
        /// </summary>
        event Action OnOpened;

        /// <summary>
        /// 关闭连接
        /// </summary>
        event Action OnClosed;

        /// <summary>
        /// 接收到消息
        /// </summary>
        event Action<string, byte[]> OnReceiveMessage;
    }
}
